

/* Written by Michael E. Kounavis, Commmunications Technology Lab,
   Intel Corporation, 2008
 */

#ifndef VORTEX_MISC_H
#define VORTEX_MISC_H

#include "int_types.h"

#if 0
#define OPTIMIZED_ASSEMBLY
#define OPTIMIZED_64
#endif

#define OPTIMIZED_64_32

#define VORTEX_SUCCESS				0
#define	VORTEX_OTHER_FAILURE		1
#define VORTEX_BAD_HASH_TYPE		2
#define VORTEX_CALL_FAILURE			3
#define VORTEX_INVALID_ROUNDS		4
#define VORTEX_INVALID_LENGTH		5
#define VORTEX_NULL_POINTER_ERROR	6

#define MAX_NUMBER_OF_ROUNDS		15


uint64_t 
cmul64(uint64_t a, 
	   uint64_t b, 
	   uint64_t *d);


uint64_t 
imul64(uint64_t a, 
	   uint64_t b, 
	   uint64_t *d);


int
rijndael_128_round(uint8_t *key,
				   uint8_t *state);

int
rijndael_256_round(uint8_t *key,
				   uint8_t *state);


int
varcpy(uint8_t *dst,
	   uint8_t *src,
	   uint32_t length);


int
varset(uint8_t *dst,
	   uint8_t val,
	   uint32_t length);


int 
init_hash_256(uint8_t *hash,
			  uint8_t *var);


int 
init_hash_512(uint8_t *hash,
			  uint8_t *var);


int
padd_128(uint8_t *res,
		 uint8_t *op1,
		 uint8_t *op2);


int
padd_256(uint8_t *res,
		 uint8_t *op1,
		 uint8_t *op2);


int
pxor_128(uint8_t *res,
		 uint8_t *op1,
		 uint8_t *op2);


int
pxor_256(uint8_t *res,
		 uint8_t *op1,
		 uint8_t *op2);


int
sbox_128(uint8_t *dst,
		 uint8_t *src);


int
sbox_256(uint8_t *dst,
		 uint8_t *src);


uint64_t
math_ceil(double d);



int
perm_128(uint8_t *dst,
		 uint8_t *src);


int
perm_256(uint8_t *dst,
		 uint8_t *src);


int
mul_128(uint8_t *res,
		uint8_t *op1,
		uint8_t *op2,
		uint8_t mul_type);


int
mul_256(uint8_t *res,
		uint8_t *op1,
		uint8_t *op2,
		uint8_t mul_type);

#endif